﻿using System.Collections.Generic;
using Newtonsoft.Json;

namespace T.FAS.Runtime.Metadata.Entity.MF
{
    // 结束节点
    public class HttpRequestNode 
    {
        [JsonProperty("data")]
        public new HttpNodeData Data { get; set; }
    }


    public class HttpNodeData
    {
        [JsonProperty("inputs")]
        public InputNodeData Inputs { get; set; }

        [JsonProperty("authorization")]
        public AuthorizationNodeData Authorization { get; set; }

        [JsonProperty("outputFields")]
        public List<HttpRequestOutputField> OutputVariables { get; set; }

        [JsonProperty("headers")]
        public List<HeaderNodeData> Headers { get; set; }
        [JsonProperty("params")]
        public List<ParamNodeData> Params { get; set; }
        [JsonProperty("bodyType")]
        public string BodyType { get; set; }
        [JsonProperty("jsonBody")]
        public Dictionary<string,object> JsonBody { get; set; }
        [JsonProperty("jsonBodyString")]
        public string JsonBodyString { get; set; }
        [JsonProperty("jsonBodyStructured")]
        public StructuredTokenData JsonBodyStructured { get; set; }
        [JsonProperty("rawTextBody")]
        public string RawTextBody { get; set; }
        [JsonProperty("rawTextBodyStructured")]
        public StructuredTokenData RawTextBodyStructured { get; set; }
        [JsonProperty("formDataBody")]
        public List<ParamNodeData> FormDataBody { get; set; }
        [JsonProperty("ssl_verify")]
        public bool Ssl_verify { get; set; }
        [JsonProperty("timeout")]
        public TimeoutNodeData Timeout { get; set; }
        [JsonProperty("label")]
        public string Label { get; set; }
        [JsonProperty("description")]
        public string Description { get; set; }
        [JsonProperty("status")]
        public string Status { get; set; }
    }
    public class InputNodeData
    {
        [JsonProperty("method")]
        public string Method { get; set; }
        [JsonProperty("url")]
        public string Url { get; set; }
        [JsonProperty("urlStructured")]
        public StructuredData UrlStructured { get; set; }
    }
    public class AuthorizationNodeData
    {
        [JsonProperty("type")]
        public string Type { get; set; }
        [JsonProperty("config")]
        public AuthorizationConfigNodeData config { get; set; }
       
    }
    public class HeaderNodeData
    {
        [JsonProperty("key")]
        public string Key { get; set; }
        [JsonProperty("value")]
        public string Value { get; set; }
        [JsonProperty("keyStructured")]
        public StructuredData KeyStructured { get; set; }
        [JsonProperty("valueStructured")]
        public StructuredData ValueStructured { get; set; }
    }
    public class AuthorizationConfigNodeData
    {
        [JsonProperty("type")]
        public string Type { get; set; }
        [JsonProperty("api_key")]
        public string ApiKey { get; set; }
        [JsonProperty("header")]
        public string Header { get; set; }
        [JsonProperty("api_keyTokens")]
        public StructuredData ApiKeyTokens { get; set; }
    }
    public class StructuredData
    {
        [JsonProperty("tokens")]
        public List<StructuredTokenData> Tokens { get; set; }
    }
    public class ParamNodeData
    {
        [JsonProperty("key")]
        public string Key { get; set; }
        [JsonProperty("value")]
        public string Value { get; set; }
        [JsonProperty("keyStructured")]
        public StructuredTokenData KeyStructured { get; set; }
        [JsonProperty("valueStructured")]
        public StructuredTokenData ValueStructured { get; set; }
    }
    public class TimeoutNodeData
    {
        [JsonProperty("write")]
        public int WriteTimeout { get; set; }
        [JsonProperty("connect")]
        public int ConnectTimeout { get; set; }
        [JsonProperty("read")]
        public int ReadTimeout { get; set; }
    }
        public class StructuredTokenData
    {
        [JsonProperty("nodeId")]
        public string NodeId { get; set; }
        [JsonProperty("variableId")]
        public string VariableId { get; set; }
        [JsonProperty("variableCode")]
        public string VariableCode { get; set; }
    }
    public class HttpRequestOutputField
    {
        [JsonProperty("variableId")]
        public string VariableId { get; set; }
        [JsonProperty("variable")]
        public string Variable { get; set; }

        [JsonProperty("type")]
        public string Type { get; set; }
    }
}
